//
//  ViewBuilderController.swift
//  EasyCoding_Example
//
//  Created by 范晓鑫 on 2021/2/10.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import UIKit

class ViewBuildController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let label = UILabel.easy(.text("我是文本"), .font(size: 14), .center, .color(.red))
        let button = UIButton.easy(.text("我是按钮"), .boldFont(size: 12), .align(.left), .color(.blue), .bg(.yellow), .corner(4), .event(self, #selector(self.onClick)))
        let b = false
        self.view.easy.config(.bg(.white))
            .build {
                label.easy.layout(.top(20), .marginX)
                button.easy.layout(.bottomTop(15), .width(80), .height(40))
                    .layout(for: .parent, .left(30))
                UIStackView.easy.config(.distribution(.fillEqually),
                                         .alignment(.fill),
                                         .axis(.horizontal))
                    .build {
                        UIView.easy(.bg(.blue))
                        UIView.easy(.bg(.red))
                        UIView.easy(.bg(.green))
                        if b {
                            UIView.easy(.bg(.yellow))
                        }
                        [UIView.easy(.bg(.orange)),
                         UIView.easy(.bg(.systemPink)),
                         UIView.easy(.bg(.gray))]
                    }.layout(.bottomTop(50), .height(100))
                    .layout(for: .parent, .marginX(50))
                
                [UIView.easy(.bg(.orange)),
                 UIView.easy(.bg(.systemPink)),
                 UIView.easy(.bg(.gray))].easy
                    .layout(first: .bottomTop(80))
                    .layout(between: .bottomTop)
                    .layout(all: .marginX, .height(30))
            }
    }
    @objc func onClick() {
        print("点击了按钮")
    }
}
